﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="guest.aspx.cs" Inherits="weikebuluo.wxgzpt.WeChat.VIP.guest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport" />
    <meta name="format-detection" content="telephone=no" />
    <link href="../all/css/message.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/Scripts/JQuery.min.js"></script>
    <script type="text/javascript" src="/Scripts/Su.common.js"></script>
<title>微留言</title>
</head>
	<script type="text/javascript">
	    var wxid = getQueryString("wxid");
	    var uid = getQueryString("uid");
	    var ActionUrl = "guest.aspx?wxid=" + wxid + "&uid=" + uid;
	    $(document).ready(function () {
	        $.ajax({
	            url: ActionUrl + "&action=bindguestbook",
	            type: "post",
	            success: function (msg) {
	                msg = eval("(" + msg + ")");
	                var str = "";
	                var str1 = "";
	                str += '<a><h2 class="first first1" style="position: relative;">请点击留言</h2></a>';
	                str += '<li class="green bounceInDown nob ly1" style="display:none"><dl><dt>';
	                str += '<input name="wxname" type="text" class="px" id="wxname1" value="" placeholder="请输入您的昵称"></dt><dt>';
	                str += '<textarea name="info" class="pxtextarea" style=" height:60px;" id="info1" value="" placeholder="请输入留言"></textarea></dt>';
	                str += '<dt><a id="showcard1" class="submit" href="javascript:void(0)">提交留言</a></dt></dl></li>';
	                for (var i = 0; i < msg.length; i++) {
	                    if (msg[i].Guestbook_Father == 0) {
	                        str += '<li id=' + msg[i].Guestbook_ID + ' class="green bounceInDown"><h3>' + msg[i].Guestbook_Name + '<span>' + msg[i].Guestbook_Time + '</span><div class="clr"></div></h3><dl>';
	                        str += '<dt class="hfinfo" date="' + msg[i].Guestbook_ID + '">' + msg[i].Guestbook_Content + '</dt></dl><dl class="huifu"><dt><span>';
	                        str += '<a class="hhbt czan" date="' + msg[i].Guestbook_ID + '" href="javascript:void(0)">回复</a>';
	                        str += '<p style="display:none;" class="hhly' + msg[i].Guestbook_ID + '">';
	                        str += '<textarea name="info" class="pxtextarea hly' + msg[i].Guestbook_ID + '"></textarea>';
	                        str += '<a  class="hhsubmit submit" date="' + msg[i].Guestbook_ID + '" href="javascript:void(0)">确定</a></p></span></dt></dl></li>';
	                        $("#list").append(str);
	                        str = "";

	                    } else {
	                        str1 += '<dl class="huifu"><dt><span>回复：' + msg[i].Guestbook_Content + ' </span></dt></dl>';
	                        $("#" + msg[i].Guestbook_Father).append(str1);
	                        str1 = "";
	                    }
	                }
	                str += '<li class="green bounceInDown nob ly2" style="display:none"><dl><dt>';
	                str += '<input name="wxname" type="text" class="px" id="wxname2" value="" placeholder="请输入您的昵称"></dt><dt>';
	                str += '<textarea name="info" class="pxtextarea" style=" height:60px;" id="info2" placeholder="请输入留言"></textarea></dt><dt>';
	                str += '<a id="showcard2" class="submit" href="javascript:void(0)">提交留言</a></dt></dl></li>';
	                str += '<a><h2 class="first first2" style="position: relative;">请点击留言</h2></a>';

	                $("#list").append(str);

	                $("#showcard1").click(function () {
	                    var btn = $(this);
	                    var wxname = $("#wxname1").val();
	                    if (wxname == '') {
	                        alert("请输入昵称");
	                        return;
	                    }
	                    var info = $("#info1").val();
	                    if (info == '') {
	                        alert("请输入内容");
	                        return;
	                    }
	                    var submitData = {
	                        nickname: wxname,
	                        info: info
	                    };
	                    $.ajax({
	                        url: ActionUrl + "&action=setly",
	                        type: "post",
	                        data: submitData,
	                        success: function (flag) {
	                            if (flag == 200) {
	                                $(".ly1").css("display", "none");
	                                $("#wxname1").val("");
	                                $("#info1").val("");
	                                window.location.href = ActionUrl;
	                                return;
	                            } else {
	                                alert("留言失败！");
	                                $(".ly1").css("display", "none");
	                                $("#wxname1").val("");
	                                $("#info1").val("");
	                                return;
	                            }
	                        }
	                    });
	                });
	                //
	                $("#showcard2").click(function () {
	                    var btn = $(this);
	                    var wxname = $("#wxname2").val();
	                    if (wxname == '') {
	                        alert("请输入昵称");
	                        return;
	                    }
	                    var info = $("#info2").val();
	                    if (info == '') {
	                        alert("请输入内容");
	                        return;
	                    }
	                    var submitData = {
	                        nickname: wxname,
	                        info: info
	                    };
	                    $.ajax({
	                        url: ActionUrl + "&action=setly",
	                        type: "post",
	                        data: submitData,
	                        success: function (flag) {
	                            if (flag == 200) {
	                                $(".ly2").css("display", "none");
	                                $("#wxname2").val("");
	                                $("#info2").val("");
	                                window.location.href = ActionUrl;
	                                return;
	                            } else {
	                                alert("留言失败！");
	                                $(".ly2").css("display", "none");
	                                $("#wxname2").val("");
	                                $("#info2").val("");
	                                return;
	                            }
	                        }
	                    });
	                });

	                //
	                $(".hhsubmit").click(function () {
	                    var objid = $(this).attr("date");
	                    var info = $(".hly" + objid).val();
	                    if (info == '') {
	                        alert("请输入内容");
	                        return;
	                    }
	                    var submitData = {
	                        fid: objid,
	                        info: info
	                    };
	                    $.ajax({
	                        url: ActionUrl + "&action=resetly",
	                        type: "post",
	                        data: submitData,
	                        success: function (flag) {
	                            if (flag == 200) {
	                                alert("留言成功，等待审核！");
	                                setTimeout('', 1000);
	                                $(".hhly" + objid).css("display", "none");
	                                $(".hly" + objid).val("");
	                                return;
	                            } else {
	                                alert("留言失败！");
	                                $(".hhly" + objid).css("display", "none");
	                                $(".hly" + objid).val("");
	                                return;
	                            }
	                        }
	                    });
	                });
	                //
	                $(".hfinfo").click(function () {
	                    var objid = $(this).attr("date");
	                    $(".hhly" + objid).slideToggle();
	                });
	                //
	                $(".hhbt").click(function () {
	                    var objid = $(this).attr("date");
	                    $(".hhly" + objid).slideToggle();
	                });
	                //
	                $(document).ready(function () {
	                    $(".first1").click(function () {
	                        $(".ly1").slideToggle();
	                    });
	                    $(".first2").click(function () {
	                        $(".ly2").slideToggle();
	                    });
	                });


	            }
	        });
	    });
	</script> 
 
<body id="message" ondragstart="return false;" onselectstart="return false;">
	<div class="container">
	  	<div class="qiandaobanner">
		  	<a href="javascript:history.go(-1);">
		  		<img src="<%=GuestbookSet_TopPic %>" style="width:100%;" />
		  	</a>
	  	</div>

		<div class="cardexplain">
			<div class="history">
				<div class="history-date">
					<ul id="list">
						</ul>
					</div>
				</div>
			</div>
		</div>
</body>
</html>
